import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
    name: 'length',
    pure: true
})
// 字符串长度限制
export class LengthPipe implements PipeTransform {
    transform(value: any, args?: any): any {
        let val;
        if (!value) {
            value = '';
        }
        if (args > 0 && value.length > args) {
            val = value.substr(0, args) + '...';
        } else {
            val = value;
        }
        return val;
    }
}
